package pl.edu.agh.se.carsexpertsystem.model;

/**
 * Model samochodu opisujacy wszystkie jego cechy.
 *
 * @author piotrek
 */
public final class CarModel {

    private String name;
    private CarManufacturer manufacturer;
    private long price;
    private int bootSize;
    private int seatCount;
    private double fuelConsumption;
    private double power;
    private CarSegment carSegment;
    private boolean fourWheelDrive = false;

    public CarModel(String name, CarManufacturer manufacturer, long price, int bootSize, int seatCount, double fuelConsumption, double power, CarSegment carSegment) {
        this.name = name;
        setManufacturer(manufacturer);
        this.price = price;
        this.bootSize = bootSize;
        this.seatCount = seatCount;
        this.fuelConsumption = fuelConsumption;
        this.power = power;
        this.carSegment = carSegment;
    }

    public int getBootSize() {
        return bootSize;
    }

    public void setBootSize(int bootSize) {
        this.bootSize = bootSize;
    }

    public boolean isFourWheelDrive() {
        return fourWheelDrive;
    }

    public void setFourWheelDrive(boolean fourWheelDrive) {
        this.fourWheelDrive = fourWheelDrive;
    }

    public double getFuelConsumption() {
        return fuelConsumption;
    }

    public void setFuelConsumption(double fuelConsuption) {
        this.fuelConsumption = fuelConsuption;
    }

    public CarManufacturer getManufacturer() {
        return manufacturer;
    }

    public void setManufacturer(CarManufacturer manufacturer) {
        this.manufacturer = manufacturer;
        if (this.manufacturer != null) {
            manufacturer.getModels().add(this);
        }
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getPower() {
        return power;
    }

    public void setPower(double power) {
        this.power = power;
    }

    public long getPrice() {
        return price;
    }

    public void setPrice(long price) {
        this.price = price;
    }

    public int getSeatCount() {
        return seatCount;
    }

    public void setSeatCount(int seatCount) {
        this.seatCount = seatCount;
    }

    public CarSegment getCarSegment() {
        return carSegment;
    }

    public void setCarSegment(CarSegment carSegment) {
        this.carSegment = carSegment;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final CarModel other = (CarModel) obj;
        if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
            return false;
        }
        if (this.manufacturer != other.manufacturer && (this.manufacturer == null || !this.manufacturer.equals(other.manufacturer))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 83 * hash + (this.name != null ? this.name.hashCode() : 0);
        hash = 83 * hash + (this.manufacturer != null ? this.manufacturer.hashCode() : 0);
        return hash;
    }
    
}
